public class Solution {
    public static boolean isAnagram(String s, String t) {
        int len1 = s.length();
        int len2 = t.length();
        char[] s1 = s.toCharArray();
        char[] s2 = t.toCharArray();
        if (len1 != len2) {
            return false;
        }
        int[] array1 = new int[26];
        int[] array2 = new int[26];
        for (int i = 0; i < len1; i++) {
            array1[s1[i]-97]++;
        }
        for (int i = 0; i < len1; i++) {
            array2[s2[i]-97]++;
        }
        for (int  i = 0; i < 26; i++) {
            if (array1[i] != array2[i]) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        String s = "ddswsdawdab";
        String t = "nnnsdsasada";
        System.out.println(isAnagram(s,t));
    }
}